package com.sxkiler.demo.datastruct;

public class ArrayStack {
    private String[] items;
    private int len;
    private int count;
    public ArrayStack(int len){
        this.count = 0;
        this.len = len;
        items = new String[len];
    }
    public boolean push(String t){
        if(count>=len)return false;
        items[count++] = t;
        return true;
    }
    public String pop(){
        if(count<=0)return null;
        return items[--count];
    }
    public int getCount(){
        return count;
    }

    public static void main(String args[]){
        ArrayStack stack = new ArrayStack(10);
        System.out.println(stack.push("121")+"="+stack.getCount());
        System.out.println(stack.push("121")+"="+stack.getCount());
        System.out.println(stack.push("121")+"="+stack.getCount());
        System.out.println(stack.push("121")+"="+stack.getCount());
        System.out.println(stack.push("121")+"="+stack.getCount());
        System.out.println(stack.push("121")+"="+stack.getCount());
        System.out.println(stack.push("121")+"="+stack.getCount());
        System.out.println(stack.push("121")+"="+stack.getCount());
        System.out.println(stack.push("121")+"="+stack.getCount());
        System.out.println(stack.push("121")+"="+stack.getCount());
        System.out.println(stack.push("121")+"="+stack.getCount());
        System.out.println(stack.pop()+"="+stack.getCount());
        System.out.println(stack.pop()+"="+stack.getCount());
        System.out.println(stack.pop()+"="+stack.getCount());
        System.out.println(stack.pop()+"="+stack.getCount());
        System.out.println(stack.pop()+"="+stack.getCount());
        System.out.println(stack.pop()+"="+stack.getCount());
        System.out.println(stack.pop()+"="+stack.getCount());
        System.out.println(stack.pop()+"="+stack.getCount());
        System.out.println(stack.pop()+"="+stack.getCount());
        System.out.println(stack.pop()+"="+stack.getCount());
        System.out.println(stack.pop()+"="+stack.getCount());
    }
}
